﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Register.Model;
using Register.BLL;
using System.Web.Script.Serialization;

namespace RegisterWeb.Manager.SystemUserManager.ashx
{
    /// <summary>
    /// HospitalInfoService 的摘要说明
    /// </summary>
    public class HospitalInfoService : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
         //   context.Response.Write("Hello World");
            List<HospitalInfo> list = new List<HospitalInfo>();
            list = HospitalInfoBLL.GetHospitalInfos();

            List<HosptialItem> itemList = new List<HosptialItem>();

            itemList.Add(new HosptialItem("00000","系统管理员",true));

            foreach (HospitalInfo info in list)
            {
                itemList.Add(new HosptialItem(info.Hospital_ID,info.Hospital_Name,false));
            }

            JavaScriptSerializer jss = new JavaScriptSerializer();
            context.Response.Write(jss.Serialize(itemList));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

    class HosptialItem
    {
        public String HosptialItemID { get; set; }
        public String HosptialItemName { get; set; }
        public Boolean selected { get; set; }

        public HosptialItem(String HosptialItemID, String HosptialItemName, Boolean HosptialItemSelect)
        {
            this.HosptialItemID = HosptialItemID;
            this.HosptialItemName = HosptialItemName;
            this.selected = HosptialItemSelect;
        }

    }
}